package integration

import (
	"context"
	pb "gitee.com/micro-services/protocol/hotel/api"
	hpb "gitee.com/micro-services/protocol/hotel/server"
)

func CreateNotice(ctx context.Context, r *pb.APICreateNoticeReq) (*pb.APICreateNoticeRsp, error) {
	rsp, err := GetProxyManger().NoticeClientProxy.CreateNotice(ctx, &hpb.CreateNoticeReq{
		CheckInNoticeContent: r.CheckInNoticeContent,
		BookingNoticeContent: r.BookingNoticeContent,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APICreateNoticeRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}

func GetNoticeInfo(ctx context.Context, r *pb.APIGetNoticeInfoReq) (*pb.APIGetNoticeInfoRsp, error) {
	rsp, err := GetProxyManger().NoticeClientProxy.GetNoticeInfo(ctx, &hpb.GetNoticeInfoReq{
		NoticeType: r.NoticeType,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIGetNoticeInfoRsp{
		NoticeContent: rsp.NoticeContent,
	}, nil
}

func DeleteNotice(ctx context.Context, r *pb.APIDeleteNoticeReq) (*pb.APIDeleteNoticeRsp, error) {
	rsp, err := GetProxyManger().NoticeClientProxy.DeleteNotice(ctx, &hpb.DeleteNoticeReq{
		NoticeID: r.NoticeID,
	})
	if err != nil {
		return nil, err
	}

	return &pb.APIDeleteNoticeRsp{
		RetCode: rsp.RetCode,
		Msg:     rsp.Msg,
	}, nil
}
